import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '用户名',
    align: 'center',
    dataIndex: 'username',
  },
  {
    title: '昵称',
    align: 'center',
    dataIndex: 'nickName',
  },
  {
    title: '邮箱',
    align: 'center',
    dataIndex: 'email',
  },
  {
    title: '手机号',
    align: 'center',
    dataIndex: 'phone',
  },
  {
    title: '累计消费金额',
    align: 'center',
    dataIndex: 'totalMoney',
  },
  {
    title: 'coins',
    align: 'center',
    dataIndex: 'accountBalance',
  },
  {
    title: 'bonus',
    align: 'center',
    dataIndex: 'bonusBalance',
  },
  {
    title: '语言',
    align: 'center',
    dataIndex: 'language',
  },
  {
    title: '订阅状态',
    align: 'center',
    dataIndex: 'isSubscription',
    customRender: ({ text }) => {
      return text ? '已订阅' : '取消订阅';
    },
  },
  {
    title: '会员状态',
    align: 'center',
    dataIndex: 'status',
    customRender: ({ text }) => {
      return text ? '不正常' : '正常';
    },
  },
  {
    title: '邮箱状态',
    align: 'center',
    dataIndex: 'emailStatus',
    customRender: ({ text }) => {
      return text ? '已验证' : '未验证';
    },
  },
  {
    title: '注册时间',
    align: 'center',
    dataIndex: 'createTime',
    customRender: ({ text }) => {
      return !text ? '' : text.length > 10 ? text.substr(0, 10) : text;
    },
  },
  {
    title: '最近活跃时间',
    align: 'center',
    dataIndex: 'lastActiveTime',
  },
  {
    title: '会员订阅次数',
    align: 'center',
    dataIndex: 'subCount',
  },
  {
    title: '会员来源',
    align: 'center',
    dataIndex: 'registerClient',
  },
  {
    title: '设备ID',
    align: 'center',
    dataIndex: 'deviceId',
  },
  {
    title: '三方账号平台',
    align: 'center',
    dataIndex: 'thirdPartyType',
  },
  {
    title: '三方账号',
    align: 'center',
    dataIndex: 'thirdUserName',
  },
  {
    title: '会员到期时间',
    align: 'center',
    dataIndex: 'memberExpireTime',
  },
];
columns.forEach((item) => {
  item.resizable = true;
});
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '登录名',
    field: 'username',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: '昵称',
    field: 'nickName',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: '创建时间',
    field: 'createTime',
    component: 'DatePicker',
    colProps: { span: 6 },
  },
  {
    label: '邮箱',
    field: 'email',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: 'phone',
    field: 'phone',
    component: 'Input',
    colProps: { span: 6 },
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
